package bargain

import (
	"activity_srv/activity"
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type BargainHelpLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewBargainHelpLogic(ctx context.Context, svcCtx *svc.ServiceContext) *BargainHelpLogic {
	return &BargainHelpLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 帮砍接口
func (l *BargainHelpLogic) BargainHelp(req *types.BargainHelpRequest) (resp *types.Response, err error) {
	help, err := l.svcCtx.ActivityRpc.BargainHelp(l.ctx, &activity.BargainHelpRequest{
		UserId: req.UserId,
		Code:   req.Code,
	})
	if err != nil {
		pkg.Error("失败", zap.Error(err))
		return nil, err
	}
	return respons.Success(help), nil
}
